package com.deer.backup.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.deer.backup.repository.SetupsRepository;
import com.deer.backup.vo.Setups;

@Service
@Transactional
public class SetupsService {

    @Autowired
    private SetupsRepository setupsRepository;
    
    // 查询所有BackUp数据
    public List<Setups> findBackUp() {
    	return setupsRepository.findAll();
    }
    
    // 获取一条数据
    public Setups getOne() {
    	Setups setups = new Setups();
    	List<Setups> list = setupsRepository.findAll();
    	if(list.size()>0) {
    		setups = list.get(0);
    	}
        return setups;
    }

    // 保存或更新数据
    public Setups saveOrUpdate(Setups setups) {
        Assert.notNull(setups, "设置不能为空");
        return setupsRepository.save(setups);
    }


}